package com.Tank.draw;

import java.util.Vector;

public class Hero extends Tank {
    Shot shot = null;
    //发射多颗子弹
    Vector<Shot> shots = new Vector<>();

    public Hero(int x, int y) {
        super(x, y);
    }

    public void shotTank() {
        switch (getDirect()) {//得到Hero对象方向
            case 0://上
                shot = new Shot(getX() + 20, getY(), 0);
                break;
            case 1:
                shot = new Shot(getX() + 60, getY() + 20, 1);
                break;
            case 2:
                shot = new Shot(getX() + 20, getY() + 60, 2);
                break;
            case 3:
                shot = new Shot(getX(), getY() + 20, 3);
                break;
        }
        //新建的Shot放入线程
        if (shots.size() < 5) {
            shots.add(shot);
        }
        //启动Shot线程
        new Thread(shot).start();
    }
}